<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_admin.xhtml">
	<ui:define name="centro">

		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />

			<br />

			<h:panelGrid columns="2">
				<p:outputLabel value="Projeto:" />
				<p:selectOneMenu value="#{productBacklogMBean.projeto}" converter="#{projetoConverter}" >
					<f:selectItem itemLabel="Selecione um projeto..." itemValue="" />
					<f:selectItems value="#{productBacklogMBean.projetos}" var="projeto" itemLabel="#{projeto.titulo}"
						itemValue="#{projeto}" />
						<p:ajax event="change" update=":form:listaProductBacklog" />
				</p:selectOneMenu>
			</h:panelGrid>
			<p />

			<p:dataTable id="listaProductBacklog" var="product" value="#{productBacklogMBean.products}" paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum Product Backlog cadastrado"
				filteredValue="#{productBacklogMBean.productsFiltro}" resizableColumns="true" selectionMode="single" rowKey="#{product.id}"
				selection="#{productBacklogMBean.productBacklog}">

				<p:ajax event="rowSelect" update=":form:formulario" oncomplete="productDialog.show()"
					listener="#{productBacklogMBean.editar}" />

				<f:facet name="header">
					Lista do Product Backlog
				</f:facet>

				<p:column headerText="Item">
					<p:outputLabel value="#{product.item}" />
				</p:column>

				<p:column headerText="Título" sortBy="#{product.titulo}" filterBy="#{product.titulo}" filterMatchMode="contains">
					<p:outputLabel value="#{product.titulo}" />
				</p:column>

				<p:column headerText="Status">
					<p:outputLabel value="#{product.status}" />
				</p:column>

				<p:column headerText="Dt. Status">
					<p:outputLabel value="#{product.dataStatus}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton value="Novo" icon="ui-icon-plus" update=":form:formulario" actionListener="#{productBacklogMBean.novo}"
						oncomplete="productDialog.show()" rendered="#{productBacklogMBean.projeto != null}"/>
				</f:facet>
			</p:dataTable>

			<p:dialog header="Product Backlog" widgetVar="productDialog" resizable="false" showEffect="clip" hideEffect="fold">
				<h:panelGrid id="formulario" columns="2" cellpadding="4">
					<p:outputLabel value="Item" />
					<p:inputText id="item" value="#{productBacklogMBean.productBacklog.item}" />

					<p:outputLabel value="Título" />
					<p:inputText id="titulo" value="#{productBacklogMBean.productBacklog.titulo}" style="width:250px" />

					<p:outputLabel value="Descrição" />
					<p:inputTextarea value="#{productBacklogMBean.productBacklog.descricao}" style="width:250px;height:100px" />

					<p:outputLabel value="Estimativa em pontos" />
					<p:inputText value="#{productBacklogMBean.productBacklog.estimativaPontos}" />

					<p:outputLabel value="Estimativa scrums por ponto" />
					<p:inputText value="#{productBacklogMBean.productBacklog.estimativaValorPonto}" />

					<p:outputLabel value="Importância" />
					<p:inputText value="#{productBacklogMBean.productBacklog.importancia}" />

					<p:outputLabel value="Scrums conclusão" />
					<p:inputText value="#{productBacklogMBean.productBacklog.valorConclusao}" />

					<p:outputLabel value="Status" />
					<p:selectOneMenu value="#{productBacklogMBean.productBacklog.status}">
						<f:selectItem itemLabel="Cadastrado" itemValue="Cadastrado" />
						<f:selectItem itemLabel="Ativo" itemValue="Ativo" />
						<f:selectItem itemLabel="Inativo" itemValue="Inativo" />
					</p:selectOneMenu>

					<p:commandButton actionListener="#{productBacklogMBean.salvar}" value="Salvar" update=":form:listaProductBacklog"
						oncomplete="productDialog.hide()" />

					<p:commandButton action="#{productBacklogMBean.deletar}" value="Deletar" rendered="#{productBacklogMBean.acao == 'editar'}"
						update=":form:listaProductBacklog" oncomplete="productDialog.hide()" />
				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>
</ui:composition>

</html>
